<template>
  <div>
    <!--地图-->
    <SuperMapLayerMap v-if="completeRefreshData==true"
              :map="map"
              :allRadioIndexData="allRadioIndexData"
              :allListData="allListData"
              :allListDataArray="allListDataArray"
              :typeCodeDataList="typeCodeDataList"
              :resetClearAllBool="resetClearAllBool"
              :dataTypeInfoArray="dataTypeInfoArray"
              :queryGeomText="queryGeomText"
              :clickLonLatArr="clickLonLatArr"
              @getDetailDataById="getDetailDataById"
              @getLegendHtml="getLegendHtml"
              @getAllTempLayersSetList="getAllTempLayersSetList"
              @getCompleteLayerReturn="getCompleteLayerReturn"
    ></SuperMapLayerMap>
    <!--根据版本查询图层数据信息表格-->
    <IndexTable v-if="resetClearAllBool==false && allTableDataBool==true"
                :allTableDataBool="allTableDataBool"
                :isSpatialDataBool="isSpatialDataBool"
                :currentLayerName="currentLayerName"
                :currentLayerCode="currentLayerCode"
                :currentVersionCode="currentVersionCode"
                :allTableDataList="allTableDataList"
                :allTableTitleList="allTableTitleList"
                :selectId="selectId"
                :total="total"
    ></IndexTable>
    <!--图层图例-->
    <div v-if="showHideLegendDivBool" class="layerMap-legend">
      <!--滚动条-->
      <el-scrollbar max-height="500px">
        <p>图例</p>
        <div v-for="item in layerShowHideArray" :key="item.code" v-show="item.show" v-html="item.legendHtml">
        </div>
        <!--计算结果图例-->
        <div v-html="resultLegendHtml"></div>
      </el-scrollbar>
    </div>
  </div>
</template>

<script setup name="SuperMapLayer">
import SuperMapLayerMap from '@/map/components/superMapLayer/map.vue';
import IndexTable from '@/map/components/superMapLayer/indexTable.vue';
import { iServerHttp } from "@/map/projMap.js";
import { getDataTypeLevel2AndDataTypeLevel3Tree,queryDataByVersionCode,queryDataById } from "@/api/datamanage/basicData/indexMap.js";
import { getDictItemsByDictDirId,queryDataByVersionCode as queryDataByVersionCodeYw,queryDataById as queryDataByIdYw } from "@/api/datamanage/sysData/indexMap.js";
import { findOneById,getAttachById } from "@/api/datamanage/tifData/tifCompute.js";

const props = defineProps(['map','layerDataTypeList','resetClearAllBool','geomText','clickLonLat','resultLegend']);
const emits = defineEmits(['getAllTempLayersSetList','getCompleteLayerReturn','completeRefreshDataReturn'])
const showHideLegendDivBool = ref(false);//是否显示图例
const layerShowHideArray = ref([]);//图层是否显示数组

/*地图传参start*/
const completeRefreshData = ref(false);//防止刷新后地图不显示
const resetClearAllBool = ref(false);//是否重置清空全部图层数组
const queryGeomText = ref("");//限制查询范围的空间数据wkt
const clickLonLatArr = ref([]);//获取点击地图经纬度
const allListData = ref([]);//地图显示数据列表
const allListDataArray = ref([]);//全部加载|移除图层信息列表
const allRadioIndexData = ref([]);//全部序号列表
//数据图层显示列表
const collapseLayerData = ref([]);
//选择图层的版本号数据列表
const typeCodeDataList = ref([]);
//是否显示图层表格数据列表
const allTableDataBool = ref(false);
//图层表格数据列表
const allTableDataList = ref([]);
//表头字段数据列表
const allTableTitleList = ref([]);
//是否为空间数据
const isSpatialDataBool = ref(false);
//总数据量
const total = ref(0);
//当前数据类型图层名称
const currentLayerName = ref("");
//当前数据类型code
const currentLayerCode = ref("");
//当前数据版本号
const currentVersionCode = ref("");
//选中1条数据的ID
const selectId = ref("");
//数据类型
const dataTypeInfoArray = ref([
  //业务系统--地震地质灾害系统
  {database:"fxfzdzzh", name: '滑坡现场调查', code: 'hpxcdc', table:"dzzh_version_file_data",url:iServerHttp()+"/iserver/services/map-fxfzdzzh/rest/maps/dzzh_version_file_data@fxfzdzzh",zIndex:8,fieldId:"dvmd_id"},
  {database:"fxfzdzzh", name: '滑坡遥感影像', code: 'hpygyx', table:"dzzh_sys_sensing_image",url:iServerHttp()+"/iserver/services/map-fxfzdzzh/rest/maps/dzzh_sys_sensing_image@fxfzdzzh",zIndex:8,fieldId:"dssi_id"},
  {database:"fxfzdzzh", name: '地貌', code: 'dm', table:"dzzh_sys_landform",url:iServerHttp()+"/iserver/services/map-fxfzdzzh/rest/maps/dzzh_sys_landform@fxfzdzzh",zIndex:6,fieldId:"dsl_id"},
  {database:"fxfzdzzh", name: '天然密度', code: 'trmd', table:"dzzh_sys_natural_density",url:iServerHttp()+"/iserver/services/map-fxfzdzzh/rest/maps/dzzh_sys_natural_density@fxfzdzzh",zIndex:6,fieldId:"dsn_id"},
  {database:"fxfzdzzh", name: '地震带', code: 'belt', table:"dzzh_sys_seismotection_belt",url:iServerHttp()+"/iserver/services/map-fxfzdzzh/rest/maps/dzzh_sys_seismotection_belt@fxfzdzzh",zIndex:6,fieldId:"belt_id"},
  {database:"fxfzdzzh", name: '地震构造区', code: 'zone', table:"dzzh_sys_seismotection_zone",url:iServerHttp()+"/iserver/services/map-fxfzdzzh/rest/maps/dzzh_sys_seismotection_zone@fxfzdzzh",zIndex:6,fieldId:"zone_id"},
  {database:"dzzhTifFile", name: '地形地貌坡度', radioLabel: 'dxdmpd', code: 'dxdmpd', table:"",url:iServerHttp()+"/iserver/services/map-dzzhTifFile/rest/maps/",zIndex:8,fieldId:""},
  {database:"dzzhTifFile", name: '地形地貌坡向', radioLabel: 'dxdmpx', code: 'dxdmpx', table:"",url:iServerHttp()+"/iserver/services/map-dzzhTifFile/rest/maps/",zIndex:8,fieldId:""},
  //基础数据系统
  {database:"datacenter", name: '省级行政区', code: 'sjxzq', table:"jc_boua2",url:iServerHttp()+"/iserver/services/map-datacenter/rest/maps/jc_boua2@datacenter",zIndex:6,fieldId:"jb_id"},
  {database:"datacenter", name: '地级行政区', code: 'djxzq', table:"jc_boua4",url:iServerHttp()+"/iserver/services/map-datacenter/rest/maps/jc_boua4@datacenter",zIndex:6,fieldId:"jb_id"},
  {database:"datacenter", name: '县级行政区', code: 'xjxzq', table:"jc_boua5",url:iServerHttp()+"/iserver/services/map-datacenter/rest/maps/jc_boua5@datacenter",zIndex:6,fieldId:"jb_id"},
  {database:"datacenter", name: '乡级行政区', code: 'xjxzq1', table:"jc_boua6",url:iServerHttp()+"/iserver/services/map-datacenter/rest/maps/jc_boua6@datacenter",zIndex:6,fieldId:"jb_id"},
  {database:"datacenter", name: '省级行政中心', code: 'sjxzzx', table:"jc_resp_province",url:iServerHttp()+"/iserver/services/map-datacenter/rest/maps/jc_resp_province@datacenter",zIndex:8,fieldId:"jrp_id"},
  {database:"datacenter", name: '地级行政中心', code: 'djxzzx', table:"jc_resp_city",url:iServerHttp()+"/iserver/services/map-datacenter/rest/maps/jc_resp_city@datacenter",zIndex:8,fieldId:"jrc_id"},
  {database:"datacenter", name: '县级行政中心', code: 'xjxzzx', table:"jc_resp_county",url:iServerHttp()+"/iserver/services/map-datacenter/rest/maps/jc_resp_county@datacenter",zIndex:8,fieldId:"jrc_id"},
  {database:"datacenter", name: '乡级行政中心', code: 'xjxzzx1', table:"jc_resp_town",url:iServerHttp()+"/iserver/services/map-datacenter/rest/maps/jc_resp_town@datacenter",zIndex:8,fieldId:"jrt_id"},
  {database:"datacenter", name: '行政村所在地', code: 'xzcszd', table:"jc_resp_village",url:iServerHttp()+"/iserver/services/map-datacenter/rest/maps/jc_resp_village@datacenter",zIndex:8,fieldId:"jrv_id"},
  {database:"datacenter", name: '遥感', code: 'yg1', table:"jc_remote_sensing",url:iServerHttp()+"/iserver/services/map-datacenter/rest/maps/jc_remote_sensing@datacenter",zIndex:6,fieldId:"jrs_id"},
  // {database:"datacenter", name: '气候', code: 'qh', table:"jc_climate", fieldId:"jc_id", spaceBool: false},
  {database:"demtif", name: 'DEM高程数据', code: 'demgcsj', table:"",url:iServerHttp()+"/iserver/services/map-demtif/rest/maps/",zIndex:6,fieldId:""},
  {database:"datacenter", name: '水系（点）', code: 'sxd', table:"jc_hydp",url:iServerHttp()+"/iserver/services/map-datacenter/rest/maps/jc_hydp@datacenter",zIndex:8,fieldId:"jh_id"},
  {database:"datacenter", name: '水系（线）', code: 'sxx', table:"jc_hydl",url:iServerHttp()+"/iserver/services/map-datacenter/rest/maps/jc_hydl@datacenter",zIndex:7,fieldId:"jh_id"},
  {database:"datacenter", name: '水系（面）', code: 'sxm', table:"jc_hyda",url:iServerHttp()+"/iserver/services/map-datacenter/rest/maps/jc_hyda@datacenter",zIndex:6,fieldId:"jh_id"},
  {database:"datacenter", name: '场地类别', code: 'cdlb1', table:"jc_site_category",url:iServerHttp()+"/iserver/services/map-datacenter/rest/maps/jc_site_category@datacenter",zIndex:8,fieldId:"jsc_id"},
  {database:"datacenter", name: '地震台站', code: 'dztz', table:"jc_observation_station",url:iServerHttp()+"/iserver/services/map-datacenter/rest/maps/jc_observation_station@datacenter",zIndex:8,fieldId:"jos_id"},
  {database:"datacenter", name: '地质灾害危险点', code: 'dzzhwxd', table:"jc_dangerous_spot",url:iServerHttp()+"/iserver/services/map-datacenter/rest/maps/jc_dangerous_spot@datacenter",zIndex:8,fieldId:"jds_id"},
  // {database:"datacenter", name: '钻孔', code: 'y02ckxx', table:"jc_rfcp_y02", fieldId:"id", spaceBool: false},
  {database:"datacenter", name: '断层', code: 'dc', table:"jc_fault",url:iServerHttp()+"/iserver/services/map-datacenter/rest/maps/jc_fault@datacenter",zIndex:7,fieldId:"id"},
  // {database:"datacenter", name: '地层岩性', code: 'dcyx1', table:"jc_stratum_lithology",url:iServerHttp()+"/iserver/services/map-datacenter/rest/maps/jc_stratum_lithology@datacenter",zIndex:6,fieldId:"id"},
  {database:"datacenter", name: '地层岩性', code: 'dcyx1', table:"jc_stratum_lithology",url:iServerHttp()+"/iserver/services/map-datacenter/rest/maps/地层岩性",zIndex:6,fieldId:"id"},
  {database:"datacenter", name: '危险性数据PGA点', code: 'wxxsjpgad', table:"jc_dangerous_pga",url:iServerHttp()+"/iserver/services/map-datacenter/rest/maps/jc_dangerous_pga@datacenter",zIndex:8,fieldId:"id"},
  {database:"datacenter", name: '危险性数据等级点', code: 'wxxsjdjd', table:"jc_dangerous_leveld",url:iServerHttp()+"/iserver/services/map-datacenter/rest/maps/jc_dangerous_leveld@datacenter",zIndex:8,fieldId:"id"},
  {database:"datacenter", name: '危险性数据等级面', code: 'wxxsjdjm', table:"jc_dangerous_levelm",url:iServerHttp()+"/iserver/services/map-datacenter/rest/maps/jc_dangerous_levelm@datacenter",zIndex:6,fieldId:"id"},
  {database:"datacenter", name: '历史4 3/4以上强震目录', code: 'ls434ysqzml', table:"jc_strong_catalog",url:iServerHttp()+"/iserver/services/map-datacenter/rest/maps/jc_strong_catalog@datacenter",zIndex:6,fieldId:"jsc_id"},
  {database:"datacenter", name: '1970年以来小震目录', code: '1970nylxzml', table:"jc_instrument_catalog",url:iServerHttp()+"/iserver/services/map-datacenter/rest/maps/jc_instrument_catalog@datacenter",zIndex:6,fieldId:"jic_id"},
  {database:"datacenter", name: 'PGA_002', code: 'pga002', table:"jc_pga_002",url:iServerHttp()+"/iserver/services/map-datacenter/rest/maps/jc_pga_002@datacenter",zIndex:6,fieldId:"jp_id"},
  {database:"datacenter", name: 'PGA_010', code: 'pga010', table:"jc_pga_010",url:iServerHttp()+"/iserver/services/map-datacenter/rest/maps/jc_pga_010@datacenter",zIndex:6,fieldId:"jp_id"},
  {database:"datacenter", name: 'PGA_063', code: 'pga063', table:"jc_pga_063",url:iServerHttp()+"/iserver/services/map-datacenter/rest/maps/jc_pga_063@datacenter",zIndex:6,fieldId:"jp_id"},
  {database:"datacenter", name: '特征周期（面属性）_002', code: 'tzzqmsx002', table:"jc_features_period_002",url:iServerHttp()+"/iserver/services/map-datacenter/rest/maps/jc_features_period_002@datacenter",zIndex:6,fieldId:"jfp_id"},
  {database:"datacenter", name: '特征周期（面属性）_010', code: 'tzzqmsx010', table:"jc_features_period_010",url:iServerHttp()+"/iserver/services/map-datacenter/rest/maps/jc_features_period_010@datacenter",zIndex:6,fieldId:"jfp_id"},
  {database:"datacenter", name: '特征周期（面属性）_063', code: 'tzzqmsx063', table:"jc_features_period_063",url:iServerHttp()+"/iserver/services/map-datacenter/rest/maps/jc_features_period_063@datacenter",zIndex:6,fieldId:"jfp_id"},
  {database:"datacenter", name: '地震综合等震线', code: 'dzzhdzx1', table:"jc_comprehensive_isoseismal",url:iServerHttp()+"/iserver/services/map-datacenter/rest/maps/jc_comprehensive_isoseismal@datacenter",zIndex:7,fieldId:"id"},
  // {database:"datacenter", name: '震害调查', code: 'zhdc1', table:"jc_earthquake_damage_survey", fieldId:"jeds_id", spaceBool: false},
  // {database:"datacenter", name: '2000年以来的震害与救灾案例', code: '2000nyldzhyjzal', table:"jc_disaster_case", fieldId:"jdc_id", spaceBool: false},
  {database:"datacenter", name: '危化企业', code: 'whqy1', table:"jc_dangerous_enterprise",url:iServerHttp()+"/iserver/services/map-datacenter/rest/maps/jc_dangerous_enterprise@datacenter",zIndex:8,fieldId:"jde_id"},
  {database:"datacenter", name: '加油（加气）站', code: 'jyjqz1', table:"jc_lfcp_gas_station",url:iServerHttp()+"/iserver/services/map-datacenter/rest/maps/jc_lfcp_gas_station@datacenter",zIndex:8,fieldId:"jgs_id"},
  {database:"datacenter", name: '危险化学品、放射危险源', code: 'wxhxpfswxy', table:"jc_dangerous_source",url:iServerHttp()+"/iserver/services/map-datacenter/rest/maps/jc_dangerous_source@datacenter",zIndex:8,fieldId:"jds_id"},
  {database:"datacenter", name: '城市避难场所', code: 'csbncs', table:"jc_emergcy_shelter",url:iServerHttp()+"/iserver/services/map-datacenter/rest/maps/jc_emergcy_shelter@datacenter",zIndex:8,fieldId:"jes_id"},
  {database:"datacenter", name: '物资储备库', code: 'wzcbk', table:"jc_material_reserve",url:iServerHttp()+"/iserver/services/map-datacenter/rest/maps/jc_material_reserve@datacenter",zIndex:8,fieldId:"jmr_id"},
  {database:"datacenter", name: '专业应急救援队伍', code: 'zyyjjydw', table:"jc_professional_relief",url:iServerHttp()+"/iserver/services/map-datacenter/rest/maps/jc_professional_relief@datacenter",zIndex:8,fieldId:"jpr_id"},
  // {database:"datacenter", name: '地震应急预案表', code: 'dzyjyab', table:"jc_emergcy_plan", fieldId:"jep_id", spaceBool: false},
  {database:"datacenter", name: '建筑物格网数据', code: 'jzwgwsj', table:"jc_ds_gpb_gdzc_grid_total_housing",url:iServerHttp()+"/iserver/services/map-datacenter/rest/maps/jc_ds_gpb_gdzc_grid_total_housing@datacenter",zIndex:6,fieldId:"jdgggth_id"},
  {database:"datacenter", name: '城镇住宅', code: 'czzz', table:"jc_risk_census_city_house",url:iServerHttp()+"/iserver/services/map-datacenter/rest/maps/jc_risk_census_city_house@datacenter",zIndex:6,fieldId:"jrcch_id"},
  {database:"datacenter", name: '城镇非住宅', code: 'czfzz', table:"jc_risk_census_city_non_house",url:iServerHttp()+"/iserver/services/map-datacenter/rest/maps/jc_risk_census_city_non_house@datacenter",zIndex:6,fieldId:"jrccnh_id"},
  {database:"datacenter", name: '农村住宅（独立住宅）', code: 'nczzdlzz', table:"jc_risk_census_country_dl_house",url:iServerHttp()+"/iserver/services/map-datacenter/rest/maps/jc_risk_census_country_dl_house@datacenter",zIndex:6,fieldId:"jrccdh_id"},
  {database:"datacenter", name: '农村住宅（集合住宅）', code: 'nczzjhzz', table:"jc_risk_census_country_jh_house",url:iServerHttp()+"/iserver/services/map-datacenter/rest/maps/jc_risk_census_country_jh_house@datacenter",zIndex:6,fieldId:"jrccjh_id"},
  {database:"datacenter", name: '辅助用房', code: 'fzyf', table:"jc_risk_census_country_fz_house",url:iServerHttp()+"/iserver/services/map-datacenter/rest/maps/jc_risk_census_country_fz_house@datacenter",zIndex:6,fieldId:"jrccfh_id"},
  {database:"datacenter", name: '农村非住宅', code: 'ncfzz', table:"jc_risk_census_country_non_house",url:iServerHttp()+"/iserver/services/map-datacenter/rest/maps/jc_risk_census_country_non_house@datacenter",zIndex:6,fieldId:"jrccnh_id"},
  {database:"datacenter", name: '房屋抗震能力分区', code: 'fwkznlfq', table:"jc_house_earthquake",url:iServerHttp()+"/iserver/services/map-datacenter/rest/maps/jc_house_earthquake@datacenter",zIndex:6,fieldId:"jhe_id"},
  {database:"datacenter", name: '铁路分布图', code: 'tlfbt', table:"jc_lrrl",url:iServerHttp()+"/iserver/services/map-datacenter/rest/maps/jc_lrrl@datacenter",zIndex:7,fieldId:"jl_id"},
  {database:"datacenter", name: '道路', code: 'dl1', table:"jc_lrdl",url:iServerHttp()+"/iserver/services/map-datacenter/rest/maps/jc_lrdl@datacenter",zIndex:7,fieldId:"jl_id"},
  {database:"datacenter", name: '桥梁', code: 'ql1', table:"jc_lfcl_bridge",url:iServerHttp()+"/iserver/services/map-datacenter/rest/maps/jc_lfcl_bridge@datacenter",zIndex:7,fieldId:"jlb_id"},
  {database:"datacenter", name: '隧道', code: 'sd1', table:"jc_lfcl_tunnel",url:iServerHttp()+"/iserver/services/map-datacenter/rest/maps/jc_lfcl_tunnel@datacenter",zIndex:7,fieldId:"jlt_id"},
  {database:"datacenter", name: '机场', code: 'jc1', table:"jc_airport",url:iServerHttp()+"/iserver/services/map-datacenter/rest/maps/jc_airport@datacenter",zIndex:8,fieldId:"ja_id"},
  {database:"datacenter", name: '直升机停机坪', code: 'zsjtjp', table:"jc_tarmac",url:iServerHttp()+"/iserver/services/map-datacenter/rest/maps/jc_tarmac@datacenter",zIndex:8,fieldId:"jt_id"},
  {database:"datacenter", name: '车站', code: 'cz1', table:"jc_lfcp_station",url:iServerHttp()+"/iserver/services/map-datacenter/rest/maps/jc_lfcp_station@datacenter",zIndex:8,fieldId:"jls_id"},
  {database:"datacenter", name: '学校表', code: 'xxb', table:"jc_rfcp_school",url:iServerHttp()+"/iserver/services/map-datacenter/rest/maps/jc_rfcp_school@datacenter",zIndex:8,fieldId:"js_id"},
  {database:"datacenter", name: '医院', code: 'yy1', table:"jc_rfcp_hospital",url:iServerHttp()+"/iserver/services/map-datacenter/rest/maps/jc_rfcp_hospital@datacenter",zIndex:8,fieldId:"jh_id"},
  {database:"datacenter", name: '尾矿库', code: 'wkk1', table:"jc_tailings_pond",url:iServerHttp()+"/iserver/services/map-datacenter/rest/maps/jc_tailings_pond@datacenter",zIndex:8,fieldId:"jtp_id"},
  {database:"datacenter", name: '旅游景点', code: 'lyjd', table:"jc_tourism_spot",url:iServerHttp()+"/iserver/services/map-datacenter/rest/maps/jc_tourism_spot@datacenter",zIndex:8,fieldId:"jts_id"},
  {database:"datacenter", name: '文物保护单位', code: 'wwbhdw', table:"jc_landmark",url:iServerHttp()+"/iserver/services/map-datacenter/rest/maps/jc_landmark@datacenter",zIndex:8,fieldId:"jl_id"},
  {database:"datacenter", name: '水库', code: 'sk1', table:"jc_reservior",url:iServerHttp()+"/iserver/services/map-datacenter/rest/maps/jc_reservior@datacenter",zIndex:8,fieldId:"jr_id"},
  {database:"datacenter", name: '油气管线', code: 'yqgx', table:"jc_pipl",url:iServerHttp()+"/iserver/services/map-datacenter/rest/maps/jc_pipl@datacenter",zIndex:7,fieldId:"jp_id"},
  // {database:"datacenter", name: '人口统计表', code: 'rktjb', table:"jc_population", fieldId:"jp_id", spaceBool: false},
  {database:"datacenter", name: '人口公里网格数据', code: 'rkglwgsj', table:"jc_population_grid",url:iServerHttp()+"/iserver/services/map-datacenter/rest/maps/jc_population_grid@datacenter",zIndex:6,fieldId:"id"},
  // {database:"datacenter", name: '国民经济统计表', code: 'gmjjtjb', table:"jc_economy", fieldId:"id", spaceBool: false},
  {database:"datacenter", name: '国民生产总值', code: 'gmsczz', table:"jc_gdp",url:iServerHttp()+"/iserver/services/map-datacenter/rest/maps/jc_gdp@datacenter",zIndex:6,fieldId:"id"},
  //业务系统--地震地质灾害系统（分布规律分析计算结果）
  {database:"fxfzdzzh", name: '地震烈度与地震地质灾害分布图', code: 'dldzz', table:"dzzh_slide_result_intensity",url:iServerHttp()+"/iserver/services/map-fxfzdzzh/rest/maps/dzzh_slide_result_intensity@fxfzdzzh",zIndex:6,fieldId:"dsri_id"},
  {database:"fxfzdzzh", name: '距断层距离与地震地质灾害分布图', code: 'djdz', table:"dzzh_slide_result_fault",url:iServerHttp()+"/iserver/services/map-fxfzdzzh/rest/maps/dzzh_slide_result_fault@fxfzdzzh",zIndex:6,fieldId:"dsrf_id"},
  {database:"fxfzdzzh", name: '地形高程分带与地震地质灾害分布图', code: 'dgdz', table:"dzzh_slide_result_tera",url:iServerHttp()+"/iserver/services/map-fxfzdzzh/rest/maps/dzzh_slide_result_tera@fxfzdzzh",zIndex:6,fieldId:"dsrt_id"},
  {database:"fxfzdzzh", name: '地形坡度与地震地质灾害分布图', code: 'dpdz', table:"dzzh_slide_result_slope",url:iServerHttp()+"/iserver/services/map-fxfzdzzh/rest/maps/dzzh_slide_result_slope@fxfzdzzh",zIndex:6,fieldId:"dsrs_id"},
  {database:"fxfzdzzh", name: '坡向与地震地质灾害分布图', code: 'pdz', table:"dzzh_slide_result_aspect",url:iServerHttp()+"/iserver/services/map-fxfzdzzh/rest/maps/dzzh_slide_result_aspect@fxfzdzzh",zIndex:6,fieldId:"dsra_id"},
  {database:"fxfzdzzh", name: '距离水系距离与地震地质灾害分布图', code: 'wjdz', table:"dzzh_slide_result_drainage",url:iServerHttp()+"/iserver/services/map-fxfzdzzh/rest/maps/dzzh_slide_result_drainage@fxfzdzzh",zIndex:6,fieldId:"dsrd_id"},
  {database:"fxfzdzzh", name: '工程地质岩组与地震地质灾害分布图', code: 'dydz', table:"dzzh_slide_result_lithology",url:iServerHttp()+"/iserver/services/map-fxfzdzzh/rest/maps/dzzh_slide_result_lithology@fxfzdzzh",zIndex:6,fieldId:"dsrl_id"},
  //业务系统--地震地质灾害系统（地表破裂带评估结果）
  {database:"fxfzdzzh", name: '地表破裂带震源', code: 'dsr', table:"dzzh_surface_rupture",url:iServerHttp()+"/iserver/services/map-fxfzdzzh/rest/maps/dzzh_surface_rupture@fxfzdzzh",zIndex:8,fieldId:"dsr_id"},
  {database:"fxfzdzzh", name: '地表破裂带', code: 'dsrf', table:"dzzh_surface_rupture_fault",url:iServerHttp()+"/iserver/services/map-fxfzdzzh/rest/maps/dzzh_surface_rupture_fault@fxfzdzzh",zIndex:7,fieldId:"id"},
  {database:"fxfzdzzh", name: '地表破裂带同震位移', code: 'dsrd', table:"dzzh_surface_rupture_displacement",url:iServerHttp()+"/iserver/services/map-fxfzdzzh/rest/maps/dzzh_surface_rupture_displacement@fxfzdzzh",zIndex:8,fieldId:"id"},
  {database:"fxfzdzzh", name: '发震构造评估区域', code: 'fgs', table:"dzzh_seismogenic_structure_stimate",url:iServerHttp()+"/iserver/services/map-fxfzdzzh/rest/maps/dzzh_seismogenic_structure_stimate@fxfzdzzh",zIndex:6,fieldId:"dsss_id"},
  //软土震陷评估结果
  {database:"fxfzdzzh", name: '软土震陷单孔结果', code: 'rtzxdkjg', table:"dzzh_soft_soil_evaluate_result",url:iServerHttp()+"/iserver/services/map-fxfzdzzh/rest/maps/dzzh_soft_soil_evaluate_result@fxfzdzzh",zIndex:8,fieldId:"sser_id"},
  {database:"fxfzdzzh", name: '软土震陷区域结果', code: 'rtzxqyjg', table:"dzzh_soft_soil_polygon_evaluate_result",url:iServerHttp()+"/iserver/services/map-fxfzdzzh/rest/maps/dzzh_soft_soil_polygon_evaluate_result@fxfzdzzh",zIndex:6,fieldId:"dssper_id"},
  //软土震陷评估结果
  {database:"fxfzdzzh", name: '砂土液化单孔结果', code: 'styhdkjg', table:"dzzh_result_sand_liquefaction",url:iServerHttp()+"/iserver/services/map-fxfzdzzh/rest/maps/dzzh_result_sand_liquefaction@fxfzdzzh",zIndex:8,fieldId:"drsl_id"},
  {database:"fxfzdzzh", name: '砂土液化区域结果', code: 'styhqyjg1', table:"dzzh_sand_liquefaction_polygon_evaluate_result",url:iServerHttp()+"/iserver/services/map-fxfzdzzh/rest/maps/dzzh_sand_liquefaction_polygon_evaluate_result1@fxfzdzzh",zIndex:6,fieldId:"dslper_id"},
  {database:"fxfzdzzh", name: '砂土液化区域结果', code: 'styhqyjg2', table:"dzzh_sand_liquefaction_polygon_evaluate_result",url:iServerHttp()+"/iserver/services/map-fxfzdzzh/rest/maps/dzzh_sand_liquefaction_polygon_evaluate_result2@fxfzdzzh",zIndex:6,fieldId:"dslper_id"},
]);
//根据ID查询数据属性表
const getDetailDataById = (temp)=>{
  console.log("开始根据ID查询数据属性表");
  let typeCode = temp.typeCode;
  let id = temp.id;
  let params = {
    typeCode : typeCode,//三级数据类别（数据表）code
    id : id,
  }
  allTableDataBool.value = false;
  allTableDataList.value = [];//清空根据ID查询数据属性表
  allTableTitleList.value = [];
  //获取数据图层名称
  currentLayerName.value = getDictItemNameByCode(typeCode);
  //当前数据类型code
  currentLayerCode.value = typeCode;
  //当前数据版本号
  currentVersionCode.value = "";
  //选中1条数据的ID
  selectId.value = id;
  //是否为空间数据
  isSpatialDataBool.value = true;
  if(temp.database=="datacenter"){//基础数据系统
    //根据ID查询数据属性表
    queryDataById(params).then((response) => {
      nextTick(() => {
        console.log("根据ID查询数据属性表");
        console.log(response.data);
        if(response.data){
          let resultList = response.data;//data,title
          allTableDataList.value = [resultList.data];
          allTableTitleList.value = resultList.title;//表头字段列表
          allTableDataBool.value = true;
          total.value = 1;
        }
      });
    });
  }else if(temp.database=="fxfzdzzh"){//业务系统
    //根据ID查询数据属性表
    queryDataByIdYw(params).then((response) => {
      nextTick(() => {
        console.log("根据ID查询数据属性表");
        console.log(response.data);
        if(response.data){
          let resultList = response.data;//data,title
          allTableDataList.value = [resultList.data];
          allTableTitleList.value = resultList.title;//表头字段列表
          allTableDataBool.value = true;
          total.value = 1;
        }
      });
    });
  }
}
//图例
const getLegendHtml = (obj)=>{
  console.log("getLegendHtml");
  console.log(obj);
  //图层显示隐藏数组
  let showHideArray = layerShowHideArray.value;
  if(obj!=null){
    for(let i=0;i<showHideArray.length;i++){
      if(showHideArray[i].name==obj.name){
        showHideArray[i].show = obj.show;
        showHideArray[i].legendHtml = obj.legendHtml;//显示图例
        break;
      }
    }
    //是否显示图例
    let bool = false;
    for(let i=0;i<showHideArray.length;i++){
      if(showHideArray[i].show){
        bool = true;
        break;
      }
    }
    showHideLegendDivBool.value = bool;
  }else{//清空图例
    //是否显示图例
    for(let i=0;i<showHideArray.length;i++){
      showHideArray[i].show = false;
    }
    showHideLegendDivBool.value = false;
  }
}
//获取全部图层信息列表
const getAllTempLayersSetList = (obj)=>{
  console.log("getAllTempLayersSetList");
  console.log(obj);
  emits('getAllTempLayersSetList', obj);
}
//完成图层加载|移除返回结果
const getCompleteLayerReturn = (obj)=>{
  console.log("getCompleteLayerReturn");
  console.log(obj);
  emits('getCompleteLayerReturn', obj);
}
/*地图传参end*/

//设置图例
function setLayerShowHideArray(){
  let showHideArray = [];
  let dataTypeArray = dataTypeInfoArray.value;
  for(let i=0;i<dataTypeArray.length;i++){
    let item = dataTypeArray[i];
    showHideArray.push({ code: item.code, name: item.name, show:false,legendHtml:"" });
  }
  layerShowHideArray.value = showHideArray;
}

//获取数据图层显示列表
const getAllTreeData = ()=>{
  /**
   * dictCode :类别code 数据类别的dictItemCode
   * 水系 sx
   * 地形地貌 高程demgc
   * 活断层 hdc
   * 道路 dl
   * 地层岩性 dcyx
   * 地震动峰值加速度数据 pgakj
   * 气候qx
   * 地震综合等震线 dzzhdzx
   */
  //查询数据类别树
  getDataTypeLevel2AndDataTypeLevel3Tree().then((response) => {
    nextTick(() => {
      console.log("查询数据类别树");
      console.log(response.data);
      let list = response.data;
      let collapseLayerDataArray = [];
      let typeCodeDataArray = [];
      let allRadioIndexArray = [];
      if(list!=null && list.length>0){
        for(let i=0;i<list.length;i++){
          let data = list[i];
          let childrenData = [];
          let children = data.children;
          for(let j=0;j<children.length;j++){
            /*let bool = false;
            if(children[j].isSpatialData==1){//空间数据
              bool = true;
            }*/
            let bool = true;//空间数据
            childrenData.push({
              name: children[j].dictItemName,
              spaceBool:bool,//是否空间数据
              dictItemCode: children[j].dictItemCode,
            });
            //选择图层的版本号数据列表
            typeCodeDataArray.push({
              name: children[j].dictItemName,
              typeCodeSelectData:[],
              dictItemCode: children[j].dictItemCode,
              spaceBool:bool,//是否空间数据
              fitBool:false,//是否缩放到范围
              queryGeomBool:true,//是否限制查询范围
            });
            //全部序号列表
            allRadioIndexArray.push(children[j].dictItemCode);//三级数据类别
          }
          let collapseData = {
            value:data.dictItemCode,
            label: data.dictItemName,
            children: childrenData,
            dictItemCode: data.dictItemCode,
          }
          collapseLayerDataArray.push(collapseData);
        }
      }
      //添加地震综合等震线
      let tempArrayObj = addTypeCodeDataList("地震综合等震线","dzzhdzx","dzzhdzx1",typeCodeDataArray,allRadioIndexArray,collapseLayerDataArray);
      //数据图层显示列表
      collapseLayerData.value = tempArrayObj.collapseLayerDataArray;
      //选择图层的版本号数据列表
      typeCodeDataList.value = tempArrayObj.typeCodeDataArray;
      console.log("typeCodeDataList.value");
      console.log(typeCodeDataList.value);
      //全部序号列表
      allRadioIndexData.value = tempArrayObj.allRadioIndexArray;
      //获取业务数据图层显示列表
      getAllYwTreeData();
    });
  });
}

//添加数据类别列表
function addTypeCodeDataList(label,level2DataType,level3DataType,typeCodeDataArray,allRadioIndexArray,collapseLayerDataArray){
  //选择图层的版本号数据列表
  typeCodeDataArray.push({
    name: label,
    typeCodeSelectData:[],
    dictItemCode: level3DataType,
    spaceBool:true,//是否空间数据
    fitBool:false,//是否缩放到范围
    queryGeomBool:true,//是否限制查询范围
  });
  //全部序号列表
  allRadioIndexArray.push(level3DataType);//三级数据类别
  let collapseData = {
    value:level2DataType,
    label: label,
    children: [{
      name: label,
      spaceBool:true,//是否空间数据
      dictItemCode: level3DataType,
    }],
    dictItemCode: level2DataType,
  }
  collapseLayerDataArray.push(collapseData);

  return {
    typeCodeDataArray:typeCodeDataArray,
    allRadioIndexArray:allRadioIndexArray,
    collapseLayerDataArray:collapseLayerDataArray
  };
}

//获取业务数据图层显示列表
const getAllYwTreeData = ()=>{
  /**
   * dictDirId:类别code dataManage
   * 滑坡现场调查
   * 滑坡遥感影像
   * 地貌
   * 天然密度
   * 地震带
   * 地震构造区
   * 地形地貌坡度
   * 地形地貌坡向
   */
  let dictDirId = "dataManage";
  //查询业务数据类别树
  getDictItemsByDictDirId(dictDirId).then((response) => {
    nextTick(() => {
      console.log("查询业务数据类别树");
      console.log(response.data);
      let list = response.data;
      //获取基础数据类别树列表
      let collapseLayerDataArray = collapseLayerData.value;
      let typeCodeDataArray = typeCodeDataList.value;
      let allRadioIndexArray = allRadioIndexData.value;
      if(list!=null && list.length>0){
        for(let i=0;i<list.length;i++){
          let data = list[i];
          let childrenData = [];
          let children = data.children;
          for(let j=0;j<children.length;j++){
            /*let bool = false;
            if(children[j].isSpatialData==1){//空间数据
              bool = true;
            }*/
            let bool = true;//空间数据
            childrenData.push({
              name: children[j].dictItemName,
              spaceBool:bool,//是否空间数据
              dictItemCode: children[j].dictItemCode,
            });
            //选择图层的版本号数据列表
            typeCodeDataArray.push({
              name: children[j].dictItemName,
              typeCodeSelectData:[],
              dictItemCode: children[j].dictItemCode,
              spaceBool:bool,//是否空间数据
              fitBool:false,//是否缩放到范围
              queryGeomBool:true,//是否限制查询范围
            });
            //全部序号列表
            allRadioIndexArray.push(children[j].dictItemCode);//三级数据类别
          }
          let collapseData = {
            value:data.dictCode,
            label: data.dictName,
            children: childrenData,
            dictItemCode: data.dictCode,
          }
          collapseLayerDataArray.push(collapseData);
        }
      }
      //数据图层显示列表
      collapseLayerData.value = collapseLayerDataArray;
      //选择图层的版本号数据列表
      typeCodeDataList.value = typeCodeDataArray;
      console.log("typeCodeDataList.value");
      console.log(typeCodeDataList.value);
      //全部序号列表
      allRadioIndexData.value = allRadioIndexArray;
      //显示地图模块
      // completeRefreshData.value = true;
      //获取业务数据计算结果图层显示列表
      getAllYwTreeResultData();
    });
  });
}

//获取业务数据计算结果图层显示列表
const getAllYwTreeResultData = ()=>{
  /**
   * dictDirId:resultManage
   * 地震综合等震线 dzzhdzx
   * 与地震烈度的关系
   * 与距断层距离的关系
   * 与高程的关系
   * 与地形坡度的关系
   * 与坡向的关系
   * 与水系的关系
   * 与地层岩性的关系
   */
  let dictDirId = "resultManage";
  //查询业务数据类别树
  getDictItemsByDictDirId(dictDirId).then((response) => {
    nextTick(() => {
      console.log("查询业务数据类别树--计算结果");
      console.log(response.data);
      let list = response.data;
      //获取基础数据类别树列表
      let collapseLayerDataArray = collapseLayerData.value;
      let typeCodeDataArray = typeCodeDataList.value;
      let allRadioIndexArray = allRadioIndexData.value;
      if(list!=null && list.length>0){
        for(let i=0;i<list.length;i++){
          let data = list[i];
          let childrenData = [];
          let children = data.children;
          if(data.dictCode=="resultsurface"){//地表破裂带评估结果
            children.push({dictItemName:"地表破裂带震源",dictItemCode:"dsr"});
            children.push({dictItemName:"地表破裂带同震位移",dictItemCode:"dsrd"});
            children.push({dictItemName:"地表破裂带",dictItemCode:"dsrf"});
            children.push({dictItemName:"发震构造评估区域",dictItemCode:"fgs"});
          }
          for(let j=0;j<children.length;j++){
            /*let bool = false;
            if(children[j].isSpatialData==1){//空间数据
              bool = true;
            }*/
            let bool = true;//空间数据
            childrenData.push({
              name: children[j].dictItemName,
              spaceBool:bool,//是否空间数据
              dictItemCode: children[j].dictItemCode,
            });
            //选择图层的版本号数据列表
            typeCodeDataArray.push({
              name: children[j].dictItemName,
              typeCodeSelectData:[],
              dictItemCode: children[j].dictItemCode,
              spaceBool:bool,//是否空间数据
              fitBool:false,//是否缩放到范围
              queryGeomBool:true,//是否限制查询范围
            });
            //全部序号列表
            allRadioIndexArray.push(children[j].dictItemCode);//三级数据类别
          }
          let collapseData = {
            value:data.dictCode,
            label: data.dictName,
            children: childrenData,
            dictItemCode: data.dictCode,
          }
          collapseLayerDataArray.push(collapseData);
        }
      }
      //数据图层显示列表
      collapseLayerData.value = collapseLayerDataArray;
      //选择图层的版本号数据列表
      typeCodeDataList.value = typeCodeDataArray;
      console.log("typeCodeDataList.value");
      console.log(typeCodeDataList.value);
      //全部序号列表
      allRadioIndexData.value = allRadioIndexArray;
      //显示地图模块
      completeRefreshData.value = true;
      emits('completeRefreshDataReturn', true);
    });
  });
}

//根据三级数据类别获取版本数据
const getLayerInfoByDictItemCode = (dictItemCode) => {
  let data = null;
  let datalist = typeCodeDataList.value;
  for(let i=0;i<datalist.length;i++){
    if(datalist[i].dictItemCode==dictItemCode){
      data = datalist[i];
      break;
    }
  }
  console.log("根据三级数据类别获取版本数据");
  console.log(typeCodeDataList.value);
  console.log(data);
  return data;
}

//根据三级数据类别（数据表）code获取数据图层名称
const getDictItemNameByCode = (typeCode) => {
  let dictItemName = "";
  let list = typeCodeDataList.value;
  for(let i=0;i<list.length;i++){
    if(list[i].dictItemCode==typeCode){
      dictItemName = list[i].name;
      break;
    }
  }

  return dictItemName;
}

//查询版本号对应图层数据（基础数据系统）
const getDataByVersionCode = (versionCode,typeCode,spatialBool,tifFileName)=>{
  console.log("开始查询版本号对应图层数据");
  /*let params = {
    typeCode : typeCode,//三级数据类别（数据表）code
    versionCode : versionCode,//版本号
    page:1,//页码
    rows:100,//分页数据量
  }*/
  allTableDataBool.value = false;
  allTableDataList.value = [];//清空图层表格数据列表
  allTableTitleList.value = [];
  //获取数据图层名称
  currentLayerName.value = getDictItemNameByCode(typeCode);
  //当前数据类型code
  currentLayerCode.value = typeCode;
  //当前数据版本号
  currentVersionCode.value = versionCode;
  //选中1条数据的ID
  selectId.value = "";

  let returnAllListData = null;
  if (typeCode == "demgcsj") {//高程
    //根据高程文件ID获取tif文件地址
    // findTifFilePathById(typeCode,versionCode,null);
    // allListData.value = [typeCode,versionCode,[],true,tifFileName];//显示超图图层
    returnAllListData = [typeCode,versionCode,[],true,tifFileName];//显示超图图层
  }else{
    // allListData.value = [typeCode,versionCode,[],true,null];//显示超图图层
    returnAllListData = [typeCode,versionCode,[],true,null];//显示超图图层
  }

  return returnAllListData;
}

//查询版本号对应图层数据（业务系统）
const getDataByVersionCodeYw = (versionCode,typeCode,spatialBool,tifFileName)=>{
  console.log("开始查询版本号对应图层数据");
  /*let params = {
    typeCode : typeCode,//三级数据类别（数据表）code
    versionCode : versionCode,//版本号
    page:1,//页码
    rows:100,//分页数据量
  }*/
  allTableDataBool.value = false;
  allTableDataList.value = [];//清空图层表格数据列表
  allTableTitleList.value = [];
  //获取数据图层名称
  currentLayerName.value = getDictItemNameByCode(typeCode);
  //当前数据类型code
  currentLayerCode.value = typeCode;
  //当前数据版本号
  currentVersionCode.value = versionCode;
  //选中1条数据的ID
  selectId.value = "";
  let returnAllListData = [typeCode,versionCode,[],true,tifFileName];//显示超图图层
  if (typeCode == "dxdmpd" || typeCode == "dxdmpx") {//坡度坡向
    //根据文件ID获取tif文件信息--坡度坡向
    // getAttachFileDataById(typeCode,versionCode,null);
    // allListData.value = [typeCode,versionCode,[],true,tifFileName];//显示超图图层
    returnAllListData = [typeCode,versionCode,[],true,tifFileName];//显示超图图层
  }else{
    // allListData.value = [typeCode,versionCode,[],true,null];//显示超图图层
    returnAllListData = [typeCode,versionCode,[],true,null];//显示超图图层
  }

  return returnAllListData;//显示超图图层
}

//设置图层选择的版本号列表（添加、移除）并查询图层数据
function setActiveTypeCodeList(versionCode,typeCode,showBool,isYw,tifFileName){
  let returnBool = false;
  let returnAllListData = null;
  //根据三级数据类别获取版本数据
  let data = getLayerInfoByDictItemCode(typeCode);
  if(data!=null && versionCode){
    let typeCodeSelectArray = data.typeCodeSelectData;
    let bool = null;//是否添加版本号
    //添加、移除版本号
    if (!typeCodeSelectArray.includes(versionCode)) {
      if(showBool){
        typeCodeSelectArray.push(versionCode);//添加
        bool = true;
      }
    } else {
      typeCodeSelectArray.forEach((id, index) => {
        if (id === versionCode) {
          if(showBool==false){
            typeCodeSelectArray.splice(index, 1);//移除
            bool = false;
          }
        }
      });
    }
    console.log("设置图层选择的版本号列表");
    console.log(typeCodeSelectArray);
    //设置图层对应的选择版本号列表
    data.typeCodeSelectData = typeCodeSelectArray;
    //是否为空间数据
    isSpatialDataBool.value = data.spaceBool;
    resetClearAllBool.value = false;//是否重置清空全部图层数组
    console.log("showBool:"+showBool+",bool:"+bool);
    //空间数据
    if(showBool && bool){//添加版本号
      //根据图层类型查询图层版本号数据
      if(isYw){
        //查询版本号对应图层数据（业务系统）
        returnAllListData = getDataByVersionCodeYw(versionCode,typeCode,true,tifFileName);
      }else{
        //查询版本号对应图层数据（基础数据系统）
        returnAllListData = getDataByVersionCode(versionCode,typeCode,true,tifFileName);
      }
      returnBool = true;
    }else if(showBool==false && bool==false){//移除版本号
      // allListData.value = [typeCode,versionCode,[],false,null];
      returnAllListData = [typeCode,versionCode,[],false,null];
      allTableDataBool.value = false;
      allTableDataList.value = [];//清空图层表格数据列表
      allTableTitleList.value = [];
      returnBool = true;
    }
  }
  return [returnBool,returnAllListData];
}

//根据高程文件ID获取tif文件地址
const findTifFilePathById = (typeCode,versionCode,id)=>{
  if(id){
    findOneById(id).then((response) => {
      nextTick(() => {
        console.log("获取文件详情");
        console.log(response.data);
        let result = response.data;
        if(result && result.fileDirId && result.attachPath){
          // attachPath: "\\tif\\/2023/05/05/坐标转换后的四川dem90米_1683254637249.tif"
          // fileDirId: "D:\\static"
          let fileDirId = result.fileDirId;
          let attachPath = result.attachPath;
          // attachPath = attachPath.replaceAll("\\/","\\");
          // attachPath = attachPath.replaceAll("/","\\");
          let filePath = fileDirId + attachPath;
          // filePath = "D:\\static\\tif\\2023\\05\\05\\坐标转换后的四川dem90米_1683254637249.tif";
          console.log(filePath);
          let attachName = result.attachName;
          let tifFileName = attachName.split(".")[0];
          allListData.value = [typeCode,versionCode,[],true,tifFileName];//显示超图图层
        }
      });
    });
  }
}

//根据文件ID获取tif文件信息--坡度坡向
const getAttachFileDataById = (typeCode,versionCode,id)=>{
  if(id){
    getAttachById(id).then((response) => {
      nextTick(() => {
        console.log("获取tif文件详情");
        console.log(response.data);
        let result = response.data;
        if(result && result.fileDirId && result.attachPath){
          let fileDirId = result.fileDirId;
          let attachPath = result.attachPath;
          // attachPath = attachPath.replaceAll("\\/","\\");
          // attachPath = attachPath.replaceAll("/","\\");
          let filePath = fileDirId + attachPath;
          console.log(filePath);
          //坡度坡向查询
          let attachName = result.attachName;
          let tifFileName = attachName.split(".")[0];
          allListData.value = [typeCode,versionCode,[],true,tifFileName];//显示超图图层
        }
      });
    });
  }
}

//根据code获取超图图层数据类型信息
function getDataTypeInfoByCode(code){
  let dataTypeInfo = null;
  if(code){
    let array = dataTypeInfoArray.value;
    for(let i=0;i<array.length;i++){
      if(code==array[i].code){
        dataTypeInfo = array[i];
        break;
      }
    }
  }

  return dataTypeInfo;
}

//清空全部已选版本号
function clearAllTypeCodeSelectData(){
  let list = typeCodeDataList.value;
  for(let i=0;i<list.length;i++){
    list[i].typeCodeSelectData = [];
  }
}

//根据数据类别code、版本号查询全部图层
function getAllLayerByVersionDataType(){
  let allDataList = [];
  let list = props.layerDataTypeList;
  for(let i=0;i<list.length;i++){
    let level2DataType = list[i].level2DataType;//数据类别二级code
    let level3DataType = list[i].level3DataType;//数据类别三级code
    let versionCode = list[i].versionCode;//版本号："全部"则展示整个图层，null无版本号不展示
    let showBool = list[i].show;//是否显示
    let isYw = list[i].isYw;//是否为业务系统数据，true业务系统，false基础数据系统
    let tifFileName = list[i].tifFileName;//tif文件名称
    console.log("versionCode:"+versionCode+",level3DataType:"+level3DataType+",show:"+showBool+",isYw"+isYw+",tifFileName"+tifFileName);
    //设置图层选择的版本号列表（添加、移除）并查询图层数据
    let returnArr = setActiveTypeCodeList(versionCode,level3DataType,showBool,isYw,tifFileName);
    let returnBool = returnArr[0];
    console.log("returnBool"+returnBool);
    let returnAllListData = returnArr[1];
    if(returnAllListData){
      allDataList.push(returnAllListData);
    }
  }
  console.log("根据数据类别code、版本号查询全部图层");
  console.log(allDataList);
  allListDataArray.value = allDataList;
}

//获取图层数据类别code和版本号
const getlayerDataTypeList = watch(() => props.layerDataTypeList, value => {// watch函数监听props.layerDataTypeList
  if(value){
    console.log("获取图层数据类别code和版本号");
    console.log(value);
    setTimeout(function(){
      //根据数据类别code、版本号查询全部图层
      getAllLayerByVersionDataType();
    },100);
  }
},{immediate:true,deep:true});

//清空全部图层
const resetClearAll = watch(() => props.resetClearAllBool, value => {// watch函数监听props.resetClearAllBool
  if(value){
    resetClearAllBool.value = true;//清空全部图层
    clearAllTypeCodeSelectData();//清空全部已选版本号
    getLegendHtml(null);//清空图例
  }
},{immediate:true});

//限制查询范围
const setQueryGeomText = watch(() => props.geomText, value => {// watch函数监听props.geomText
  if(value){
    queryGeomText.value = value;
  }else{
    queryGeomText.value = "";
  }
},{immediate:true});

//获取点击地图经纬度
const getClickLonLat = watch(() => props.clickLonLat, value => {// watch函数监听props.clickLonLat
  if(value){
    console.log("传递点击地图经纬度");
    console.log(value);
    clickLonLatArr.value = value;
  }
},{immediate:true});

//计算结果图例
const resultLegendHtml = ref("");
//获取计算结果图例
const getResultLegendHtml = watch(() => props.resultLegend, value => {// watch函数监听props.resultLegend
  if(value){
    console.log("获取计算结果图例");
    console.log(value);
    //计算结果图例
    resultLegendHtml.value = value;
  }
},{immediate:true});

onMounted(() => {
  setLayerShowHideArray();
  getAllTreeData();//获取数据图层显示列表
})
</script>

<style scoped lang="scss">
//图例
.layerMap-legend {
  position: absolute;
  right: 10px;
  bottom: 10px;
  min-height: 50px;
  background: #fff;
  padding: 10px;
  overflow: auto;
  min-width: 200px;
  box-shadow: 0px 0px 20px rgba(0,0,0,0.2);
  border:1px solid #707070;
  border-radius: 4px;
}
.layerMap-legend p:first-child{
  text-align: center;font-weight: bold;
}
</style>